home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Portable Patmos / src / portable kernel / mac / patch0.c.vm < prev    next >
Encoding:
Text File  |  1995-06-27  |  1.1 KB  |  61 lines  |  [TEXT/KAHL]

  1.      {
  2.      static long saved_usp;
  3. #ifdef MMU68040
  4.     cpusha();
  5. #endif
  6.     pflusha();
  7.     /* save the current context */
  8.          {
  9.          struct userregs save;
  10.         asm { 
  11.             movem.l    d0-d7/a0-a5,save.save
  12.             move.l    (a6),save.save[14]
  13.             move.w    4(a6),save.flags
  14.             move.l    6(a6),save.pc
  15.             };
  16.         SetCurrentA5();
  17.         save.save[15] = usp();
  18.         if (0x2000&~save.flags)
  19.             {
  20.             if (virtual) put_usp(saved_usp);
  21.             crp->registers = save;
  22.             crp->state = 'D';
  23.             }
  24.         else crp->state = 'R';
  25.         if (virtual)
  26.             {
  27.             asm
  28.                 {
  29.                 move.w    save.flags,sr
  30.                 }
  31.             }
  32.         }
  33.     memcpy(system_vectors, supervisor_vectors, vec_patch_size);
  34.     sched();
  35.     /* restore the chosen context */
  36.          {
  37.          struct userregs save;
  38.          put_user_root((long)crp);
  39.          if (virtual)
  40.              {
  41.              EnterSupervisorMode();
  42.              saved_usp = usp();
  43.              }
  44.         else upper_space(crp, crp->stack_limit-save.save[15]+stack_headroom);
  45.         save = crp->registers;
  46.         put_usp(save.save[15]);
  47.         memcpy(system_vectors, user_vectors, vec_patch_size);
  48.         cpusha();
  49.         pflusha();
  50.         asm
  51.             {
  52.             move.l    save.save[14],(a6)
  53.             move.w    save.flags,4(a6)
  54.             move.l    save.pc,6(a6)
  55.             movem.l    save.save,d0-d7/a0-a5
  56.             unlk    a6
  57.              rte 
  58.              };
  59.         }
  60.      }
  61.